from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time


driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
driver.maximize_window()

# 搜索框输入
driver.find_element_by_id('kw').send_keys('selenium')

# 删除m
driver.find_element_by_id('kw').send_keys(Keys.BACK_SPACE)

# 加空格和教程
driver.find_element_by_id('kw').send_keys(Keys.SPACE)
driver.find_element_by_id('kw').send_keys('教程')

# 组合键ctrl+a全选
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'a')

# 回车
driver.find_element_by_id('kw').send_keys(Keys.ENTER)

# F12
driver.find_element_by_id('kw').send_keys(Keys.F12)

time.sleep(3)
driver.quit()

